package demo;

import demo.impl.AliStrategy;
import demo.impl.WechatStrategy;


public class SF {
    public static void main(String[] args) throws Exception {
        SF strategicFactory = new SF();
        String payMethod = "微信";
        PaymentStrategy paymentStrategy = strategicFactory.getPayMethod(payMethod);
        paymentStrategy.pay(20);
    }

    private PaymentStrategy getPayMethod(String payMethod) throws Exception {
        switch (payMethod) {
            case "支付宝":
                return new AliStrategy();
            case "微信":
                return new WechatStrategy();
        }
        throw new Exception();
    }
}